package thread;

public class DaemonThreadDemo {
    public static void main(String[] args) {
        Thread rose = new Thread(){
            public void run(){
                for(int i = 0; i < 5; i++){
                    try {
                        System.out.println("Rose: Let me go !");
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                System.out.println("Rose: I am going !");
                System.out.println("Rose: dead !");
            }
        };
        Thread jack = new Thread(){
            public void run(){
                for(int i = 0; i < 10; i++){
                    try {
                        System.out.println("Jack: You jump! I jump!");
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        };
        rose.start();
        jack.setDaemon(true);
        jack.start();
        //while (true);//主程序死循环
    }
}
